'use strict';
module.exports = {
	/**
	 * 删除账本关联关系
	 * @url client/accountbook/kh/delUserRelationBook 前端调用的url参数地址
	 * data 请求参数
	 * @params {String} accountBookName  账本名称
	 * @params {String} accountType  账本类型
	 * @params {String} remarks  账本说明
	 */
	main: async (event) => {
		let { data = {}, userInfo, util, originalParam } = event;
		let { customUtil, config, pubFun, vk, db, _ } = util;
		let { uid, _id, bookId } = data && data;
		let res = { code : 0, msg : '删除成功' };
		// 业务逻辑开始-----------------------------------------------------------
		if(pubFun.isEmpty(_id) || pubFun.isEmpty(bookId)){
			return { code : 1001, msg : '参数错误' };
		}
		
		// 删除账本
		const row = await vk.daoCenter.userRelationBookDao.del({
			uid: _id,
			bookId: bookId
		});
		if (row == null || row <= 0) {
			throw new Error("删除失败");
		}
		
		// 业务逻辑结束-----------------------------------------------------------
		return res;
	}
}
